<template>
	<view>
		<u-cell-group style="background-color: #fff;">
				<u-cell  title="账号设置" @click="setAccont" isLink v-if="userInfo.id"></u-cell>
				<u-cell  title="训练设置" @click="setTrain" isLink v-if="userInfo.id"></u-cell>
				<u-cell   title="隐私政策"  @click="policy" isLink></u-cell>
				<u-cell   title="用户协议"  @click="agreement" isLink></u-cell>
				<u-cell   title="客服热线"  value="17671078240"></u-cell>
				<u-cell   title="检测更新"  @click="update" :value="`当前版本 V.${this.appInfo.version}`"></u-cell>
		</u-cell-group>
		<u-row style="background-color: #fff;padding: 30rpx 0;margin-top: 20rpx;" v-if="userInfo.id">
			<u--text text='退出登录' color='#ff0000' @click='exitLogin' align='center'></u--text>
		</u-row>
		<u-row style=" margin-top: 160rpx;">
			<u-col span="12">
				<u--text text='Copyright©2020-2022 All rights reserved' color='#545454' size='23rpx' align='center'></u--text>
				<u--text text='北京云码科技发展有限公司' color='#545454' size='23rpx' align='center'></u--text>
			</u-col>
		</u-row>
	</view>
</template>

<script>
	var that
	export default { 
		data() {
			return {
				userInfo:{}
			}
		},
		mounted() {
			
		},
		onLoad() {
			that = this
		 
		},
		onShow() {
			let userInfo = uni.getStorageSync('userInfo')
				
			if(userInfo){
				this.userInfo = userInfo
			}
		},
		methods: {
			setTrain(){
				uni.navigateTo({
					url:'setTrain/setTrain'
				})
			},
			setAccont(){ 
				uni.navigateTo({
					url:'accontSet/accontSet'
				})
			},
			getVer(str){
				let newStr = ''
				for(let item of str){
					if(typeof (item - 0) == 'number' && !isNaN((item - 0))){
						newStr += item
					}  
				}
			 
				return  newStr 
			},
			update(){
				 
				uni.showLoading({
					title:'检查中',
					mask:true
				})
			 this.$util.upadteApp(res=>{
				 
				 if(res.rows.length == 0){
					 uni.$u.toast('暂无更新')
				 }
			 })
			},
			agreement(){
				uni.navigateTo({
					url:'userAgreement/userAgreement'
				})
			},
			policy(){
				uni.navigateTo({
					url:'privacyPolicy/privacyPolicy'
				})
			},
			exitLogin(){
				uni.showModal({
					title: '提示',
					content: '确定退出登录吗？',  
					success: res => {
						if(res.confirm){
							that.userInfo = {}
							uni.clearStorageSync()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>

</style>
